<% layout('/layouts/default.html', {title: '报关管理', libs: ['validate','fileupload','dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header with-border">
			<div class="box-title">
				<i class="fa icon-note"></i> ${text(customsDeclaration.isNewRecord ? '新增报关' : '编辑报关')}
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${customsDeclaration}" action="${ctx}/logistics/customsdeclaration/customsDeclaration/save" method="post" class="form-horizontal">
			<div class="box-body">
				<div class="form-unit">${text('基本信息')}</div>
				<#form:hidden path="customsDeclarationId"/>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('单据编号')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="customsDeclarationCode" readonly="true" placeholder="自动生成" maxlength="100" class="form-control" />
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('服务订单')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
                                <#form:select path="serviceOrderId" items="${listServiceOrder}"
                                itemLabel="serviceOrderCode" itemValue="serviceOrderId" blankOption="true" class="form-control " readonly="true" />
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('客户名称')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
                                <#form:select path="customerId" items="${listCustomer}"
                                itemLabel="customerName" itemValue="customerId" blankOption="true" class="form-control"  readonly="true" />
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('信用证编号')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="letterCreditCode" items="${listLetterCredit}"
                                itemLabel="letterCreditCode" itemValue="letterCreditId" blankOption="true" class="form-control" readonly="true" />
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('币种')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="currency" dictType="sys_bizhong" blankOption="true" class="form-control" readonly="true" />
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('资方')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
                                <#form:select path="investorId" items="${listSupplier}"
                                itemLabel="supplierName" itemValue="supplierId" blankOption="true" class="form-control " readonly="true" />
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('报关通知')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
                                <#form:select path="customsDeclarationNoticeCode" items="${listDeclarationNotice}"
                                itemLabel="customsDeclarationNoticeCode" itemValue="customsDeclarationNoticeId" blankOption="true" class="form-control " readonly="true" />
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('报关行')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
                                <#form:select path="customsBroker" items="${listSupplier}"
                                itemLabel="supplierName" itemValue="supplierId" blankOption="true" class="form-control " readonly="true" />
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('放行日期')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="date" readonly="true" maxlength="20" class="form-control laydate required"
									dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('申报日期')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="declareDate" readonly="true" maxlength="20" class="form-control laydate required"
									dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> ${text('备注信息')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:textarea path="remarks" rows="4" maxlength="500" class="form-control"/>
							</div>
						</div>
					</div>
				</div>
                <div class="form-unit">${text('车辆信息')}</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('缴税方式')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="taxPaymentMethod" dictType="tax_payment_method" blankOption="true" class="form-control" />
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('缴税单位')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="taxPaymentWay" dictType="tax_payment_name" blankOption="true" class="form-control" />
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('出税日期')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="taxDate" readonly="true" maxlength="20" class="form-control laydate required"
									dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('缴税截止日期')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="taxDeadlineDate" readonly="true" maxlength="20" class="form-control laydate required"
									dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('实际缴税日期')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="actualTaxDate" readonly="true" maxlength="20" class="form-control laydate"
									dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('收到报关单据日期')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="customsDeclarationDate" readonly="true" maxlength="20" class="form-control laydate"
									dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('收到报关单日期')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="billDate" readonly="true" maxlength="20" class="form-control laydate"
									dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
							</div>
						</div>
					</div>
				</div>
                <div class="ml10 mr10">
                    <table id="customsDeclarationDetailDataGrid"></table>
                    <!--<% if (hasPermi('logistics:customsdeclaration:customsDeclaration:edit')){ %>
                    <a href="#" id="customsDeclarationDetailDataGridAddRowBtn" class="btn btn-primary btn-sm mt10 mb10"><i class="fa fa-plus"></i> ${text('增行')}</a>
                    <% } %>-->
                </div>
                <div class="form-unit">${text('附件信息')}</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2">
								<span class="required hide">*</span> ${text('图片上传')}：</label>
							<div class="col-sm-10">
								<#form:fileupload id="uploadImage" bizKey="${customsDeclaration.id}" bizType="customsDeclaration_image"
									uploadType="image" class="" readonly="false" preview="true"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2">
								<span class="required hide">*</span> ${text('附件上传')}：</label>
							<div class="col-sm-10">
								<#form:fileupload id="uploadFile" bizKey="${customsDeclaration.id}" bizType="customsDeclaration_file"
									uploadType="all" class="" readonly="false" preview="true"/>
							</div>
						</div>
					</div>
				</div>
                <div class="form-unit">${text('系统信息')}</div>
                <div class="row">
                    <div class="col-xs-6">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required hide">*</span> ${text('创建日期')}：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <#form:input path="createDate" class="form-control" disabled="true"
                                dataFormat="datetime2" data-type="datetime" data-format="yyyy-MM-dd HH:mm:ss"/>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-6">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required hide">*</span> ${text('创建人')}：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <#form:input path="createBy" class="form-control" disabled="true"/>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-6">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required hide">*</span> ${text('最后修改日期')}：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <#form:input path="updateDate" readonly="true" maxlength="20" class="form-control"
                                dataFormat="datetime2" data-type="datetime" data-format="yyyy-MM-dd HH:mm:ss"/>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-6">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required hide">*</span> ${text('最后修改人')}：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <#form:input path="updateBy" readonly="true" maxlength="20" class="form-control"/>
                            </div>
                        </div>
                    </div>
                </div>
			</div>
			<div class="box-footer">
				<div class="row">
					<div class="col-sm-offset-2 col-sm-10">
						<% if (hasPermi('logistics:customsdeclaration:customsDeclaration:edit')){ %>
							<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('保 存')}</button>&nbsp;
						<% } %>
						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>
//初始化报关单明细DataGrid对象
$("#customsDeclarationDetailDataGrid").dataGrid({

	data: ${toJson(customsDeclaration.customsDeclarationDetailList)},
	datatype: "local", // 设置本地数据
	autoGridHeight: function(){return 'auto'}, // 设置自动高度

	// 设置数据表格列
	columnModel: [
		{header:'状态', name:'status', editable:true, hidden:true},
		{header:'主键', name:'customsDeclarationDetailId', editable:true, hidden:true},
        {header:'${text("车架号")}', name:'frameNumber', editable:true, hidden:true},
		{header:'${text("车架号")}', name:'frameNumber', width:150, editable:false, edittype:'text', editoptions:{'maxlength':'100', 'class':'form-control'}},
		{header:'${text("行号")}', name:'rowNumber', editable:true, hidden:true},
		{header:'${text("行号")}', name:'rowNumber', width:150, editable:false, edittype:'text', editoptions:{'maxlength':'100', 'class':'form-control'}},
        {header:'${text("车辆")}', name:'carId', editable:true, hidden:true},
        {header:'${text("车辆")}', name:'carName', editable:false, width:300, edittype:'text', editoptions:{'maxlength':'255', 'class':'form-control'}},
        /*{header:'${text("车辆")}', name:'carId', width:300, editable:true, edittype:'select', editoptions:{'maxlength':'64', 'class':'form-control',
                items: ${toJson(lictCar)},
                itemLabel: 'carName', itemValue: 'carId', dataInit: function(element){
                    $(element).select2().on("change",function(){
                        $(this).resetValid();
                    });
                }
        }},*/
        {header:'${text("外币价格")}', name:'foreignCurrencyPrice', editable:true, hidden:true},
		{header:'${text("外币价格")}', name:'foreignCurrencyPrice', width:150, editable:false, edittype:'text', editoptions:{'class':'form-control number'}},
		{header:'${text("申报价格")}', name:'declaredPrice', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control required number'}},
		{header:'${text("出税价格")}', name:'taxPrice', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control required number',
                dataInit: function(element){
                    $(element).change(function(){
                        var taxPrice = zeroZhuan($(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_taxPrice"] .editable').val());
                        var taxRateH = zeroZhuan($(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_customsExchangeRate"] .editable').val());
                        var taxRateZ = zeroZhuan($(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_customsCombinedTaxRate"] .editable').val());
                        if (taxRateH != 0 && taxRateZ != 0){
                            var taxRateTo = calcDiv(taxPrice,taxRateH);
                            var taxRateTotal = calcDiv(taxRateTo,taxRateZ).toFixed(4);
                            $(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_taxPriceF"] .editable').val(taxRateTotal);
                            $(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_taxPriceF1"]').text(taxRateTotal);
                        }else {
                            $(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_taxPriceF"] .editable').val(0);
                            $(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_taxPriceF1"]').text(0);
                        }
                    });
                }
		}},
		{header:'${text("海关汇率(%)")}', name:'customsExchangeRate', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'10', 'class':'form-control required',
                dataInit: function(element){
                    $(element).change(function(){
                        var taxPrice = zeroZhuan($(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_taxPrice"] .editable').val());
                        var taxRateH = zeroZhuan($(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_customsExchangeRate"] .editable').val());
                        var taxRateZ = zeroZhuan($(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_customsCombinedTaxRate"] .editable').val());
                        if (taxRateH != 0 && taxRateZ != 0){
                            var taxRateTo = calcDiv(taxPrice,taxRateH);
                            var taxRateTotal = calcDiv(taxRateTo,taxRateZ).toFixed(4);
                            $(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_taxPriceF"] .editable').val(taxRateTotal);
                            $(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_taxPriceF1"]').text(taxRateTotal);
                        }else {
                            $(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_taxPriceF"] .editable').val(0);
                            $(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_taxPriceF1"]').text(0);
                        }
                    });
                }
		}},
		{header:'${text("海关综合税率(%)")}', name:'customsCombinedTaxRate', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'10', 'class':'form-control required',
                dataInit: function(element){
                    $(element).change(function(){
                        var taxPrice = zeroZhuan($(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_taxPrice"] .editable').val());
                        var taxRateH = zeroZhuan($(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_customsExchangeRate"] .editable').val());
                        var taxRateZ = zeroZhuan($(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_customsCombinedTaxRate"] .editable').val());
                        if (taxRateH != 0 && taxRateZ != 0){
                            var taxRateTo = calcDiv(taxPrice,taxRateH);
                            var taxRateTotal = calcDiv(taxRateTo,taxRateZ).toFixed(4);
                            $(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_taxPriceF"] .editable').val(taxRateTotal);
                            $(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_taxPriceF1"]').text(taxRateTotal);
                        }else {
                            $(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_taxPriceF"] .editable').val(0);
                            $(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_taxPriceF1"]').text(0);
                        }
                    });
                }
		}},
		{header:'${text("进口关税")}', name:'importDuty', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control required number',
                dataInit: function(element){
                    $(element).change(function(){
                        var importMon = zeroZhuan($(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_importDuty"] .editable').val());
                        var importCon = zeroZhuan($(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_importConsumptionTax"] .editable').val());
                        var importVat = zeroZhuan($(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_importVat"] .editable').val());
                        var totalAmo = calcAdd(importMon,importCon);
                        var totalAmount = calcAdd(importVat,totalAmo).toFixed(4);
                        $(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_comprehensiveTax"] .editable').val(totalAmount);
                        $(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_comprehensiveTax1"]').text(totalAmount);
                    });
                }
        }},
		{header:'${text("进口消费税")}', name:'importConsumptionTax', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control required number',
                dataInit: function(element){
                    $(element).change(function(){
                        var importMon = zeroZhuan($(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_importDuty"] .editable').val());
                        var importCon = zeroZhuan($(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_importConsumptionTax"] .editable').val());
                        var importVat = zeroZhuan($(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_importVat"] .editable').val());
                        var totalAmo = calcAdd(importMon,importCon);
                        var totalAmount = calcAdd(importVat,totalAmo).toFixed(4);
                        $(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_comprehensiveTax"] .editable').val(totalAmount);
                        $(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_comprehensiveTax1"]').text(totalAmount);
                    });
                }
		}},
		{header:'${text("进口增值税")}', name:'importVat', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control required number',
                dataInit: function(element){
                    $(element).change(function(){
                        var importMon = zeroZhuan($(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_importDuty"] .editable').val());
                        var importCon = zeroZhuan($(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_importConsumptionTax"] .editable').val());
                        var importVat = zeroZhuan($(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_importVat"] .editable').val());
                        var totalAmo = calcAdd(importMon,importCon);
                        var totalAmount = calcAdd(importVat,totalAmo).toFixed(4);
                        $(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_comprehensiveTax"] .editable').val(totalAmount);
                        $(this).closest('tr').find('[aria-describedby="customsDeclarationDetailDataGrid_comprehensiveTax1"]').text(totalAmount);
                    });
                }
		}},
        {header:'${text("综合税金")}', name:'comprehensiveTax', editable:true, hidden:true},
		{header:'${text("综合税金")}', name:'comprehensiveTax1', width:150, editable:false, edittype:'text', editoptions:{'class':'form-control number'}},
		{header:'${text("补税金额")}', name:'taxAmount', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control number'}},
		{header:'${text("其他")}', name:'other', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control number'}},
        {header:'${text("出税价格")}', name:'taxPriceF', editable:true, hidden:true},
		{header:'${text("出税价格")}', name:'taxPriceF1', width:150, editable:false, edittype:'text', editoptions:{'class':'form-control number'}},
		{header:'${text("报关单ID")}', name:'customsDeclarationId.customsDeclarationId', editable:true, hidden:true},
		{header:'${text("操作")}', name:'actions', width:80, sortable:false, fixed:true, hidden:true, formatter: function(val, obj, row, act){
			var actions = [];
			if (val == 'new'){
				actions.push('<a href="#" onclick="js.confirm(\'${text("你确认要删除这条数据吗？")}\', function(){$(\'#customsDeclarationDetailDataGrid\').dataGrid(\'delRowData\',\''+obj.rowId+'\')});return false;"><i class="fa fa-trash-o"></i></a>&nbsp;');
			}else{
				actions.push('<a href="#" onclick="js.confirm(\'${text("你确认要删除这条数据吗？")}\', function(){$(\'#customsDeclarationDetailDataGrid\').dataGrid(\'setRowData\',\''+obj.rowId+'\',null,{display:\'none\'});$(\'#'+obj.rowId+'_status\').val(\''+Global.STATUS_DELETE+'\');});return false;"><i class="fa fa-trash-o"></i></a>&nbsp;');
			}
			return actions.join('');
		}, editoptions: {defaultValue: 'new'}}
	],

	// 编辑表格参数
	editGrid: true,				// 是否是编辑表格
	editGridInitRowNum: 0,		// 编辑表格的初始化新增行数
	editGridAddRowBtn: $('#customsDeclarationDetailDataGridAddRowBtn'),	// 子表增行按钮
	editGridAddRowInitData: {customsDeclarationDetailId: '', status: Global.STATUS_NORMAL},	// 新增行的时候初始化的数据

	// 编辑表格的提交数据参数
	editGridInputFormListName: 'customsDeclarationDetailList', // 提交的数据列表名
	editGridInputFormListAttrs: 'status,customsDeclarationDetailId,frameNumber,carId,foreignCurrencyPrice,declaredPrice,taxPrice,customsExchangeRate,customsCombinedTaxRate,importDuty,importConsumptionTax,importVat,comprehensiveTax,taxAmount,other,taxPriceF,customsDeclarationId.customsDeclarationId,rowNumber', // 提交数据列表的属性字段

	// 加载成功后执行事件
	ajaxSuccess: function(data){

	}
});
</script>
<script>
$("#inputForm").validate({
	submitHandler: function(form){
		js.ajaxSubmitForm($(form), function(data){
			js.showMessage(data.message);
			if(data.result == Global.TRUE){
				js.closeCurrentTabPage(function(contentWindow){
					contentWindow.page();
				});
			}
		}, "json");
    }
});
</script>



<script>
    /**
     * 加法函数
     *
     * @param arg1
     * @param arg2
     * @returns {number}
     */
    function calcAdd(arg1, arg2) {
        var r1, r2, m, c;
        try {
            r1 = arg1.toString().split(".")[1].length;
        } catch (e) {
            r1 = 0;
        }
        try {
            r2 = arg2.toString().split(".")[1].length;
        } catch (e) {
            r2 = 0;
        }
        c = Math.abs(r1 - r2);
        m = Math.pow(10, Math.max(r1, r2));
        if (c > 0) {
            var cm = Math.pow(10, c);
            if (r1 > r2) {
                arg1 = Number(arg1.toString().replace(".", ""));
                arg2 = Number(arg2.toString().replace(".", "")) * cm;
            } else {
                arg1 = Number(arg1.toString().replace(".", "")) * cm;
                arg2 = Number(arg2.toString().replace(".", ""));
            }
        } else {
            arg1 = Number(arg1.toString().replace(".", ""));
            arg2 = Number(arg2.toString().replace(".", ""));
        }
        return (arg1 + arg2) / m;
    }

    /**
     * 减法函数
     *
     * @param arg1
     * @param arg2
     * @returns {String}
     */
    function calcSub(arg1, arg2) {
        var r1, r2, m, n;
        try {
            r1 = arg1.toString().split(".")[1].length;
        } catch (e) {
            r1 = 0;
        }
        try {
            r2 = arg2.toString().split(".")[1].length;
        } catch (e) {
            r2 = 0;
        }
        m = Math.pow(10, Math.max(r1, r2)); // last modify by deeka //动态控制精度长度
        n = (r1 >= r2) ? r1 : r2;
        return ((arg1 * m - arg2 * m) / m).toFixed(n);

    }

    /**
     * 乘法函数
     *
     * @param arg1
     * @param arg2
     * @returns {Number}
     */
    function calcMul(arg1, arg2) {
        var m = 0, s1 = arg1.toString(), s2 = arg2.toString();
        try {
            m += s1.split(".")[1].length
        } catch (e) {
        }
        try {
            m += s2.split(".")[1].length
        } catch (e) {
        }
        return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
    }

    /**
     * 除法函数
     *
     * @param arg1
     * @param arg2
     * @returns {Number}
     */
    function calcDiv(arg1, arg2) {
        var t1 = 0, t2 = 0, r1, r2;
        try {
            t1 = arg1.toString().split(".")[1].length;
        } catch (e) {
        }
        try {
            t2 = arg2.toString().split(".")[1].length;
        } catch (e) {
        }
        with (Math) {
            r1 = Number(arg1.toString().replace(".", ""));
            r2 = Number(arg2.toString().replace(".", ""));
            return (r1 / r2) * pow(10, t2 - t1);
        }
    }

    /**
     * Null 转换成 0
     *
     * @param data
     * @returns {number}
     * @constructor
     */
    function zeroZhuan(data) {
        return data ? data : 0;
    }
</script>
